package com.baiwei.vpnapi.entity.reqentity;

import com.baiwei.vpnapi.exception.AdminException;
import com.baiwei.vpnapi.exception.BusinessEnum;

/**
 * @program: vpnapi
 * @description: 推送请求输入
 * @author: Mr. Stone
 * @create: 2020-03-09 18:37
 **/

public class PushInput implements Validatable{
    // 平台 ios, andriod
    private String platform;
    // 推送内容
    private String content;
    // 推送标题
    private String title;

    public String getPlatform() {
        return platform;
    }

    public void setPlatform(String platform) {
        this.platform = platform;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public void validation() {
        if(platform == null ) {
            throw new AdminException(BusinessEnum.ADMIN_PUSH_PLATFORM_EMPTY);
        }

        if(!platform.equals("ios") && !platform.equals("andriod") && !platform.equals("all")) {
            throw new AdminException(BusinessEnum.ADMIN_PUSH_PLATFORM_NOT_SUPPORT);
        }

        if(title == null || title.length() == 0) {
            throw new AdminException(BusinessEnum.ADMIN_PUSH_TITLE_EMPTY);
        }

        if(content == null || content.length() == 0) {
            throw new AdminException(BusinessEnum.ADMIN_PUSH_CONTENT_EMPTY);
        }

    }

    public PushInput(String platform, String content, String title) {
        this.platform = platform;
        this.content = content;
        this.title = title;
    }

    public PushInput() {
    }
}
